- /* slfllcmp.cpp by K.Tsuru */
- // function ID = 206 DRADIX, BRADIX
- /*******************************************************
- SLong and SInteger classes
- Comparing |m| and |n| it returns the following values.
- |m| > |n| : 1
- |m| == |n| : 0
- |m| < |n| : -1
- which are the same as strcmp() and memcmp().
- ********************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
-
- int LLCompare(const SLong& m, const SLong& n) {
- // m = 0 || n = 0
- if(!m.Sign(206) || !n.Sign(206)) return abs(m.Sign()) - abs(n.Sign());
- if(&m == &n) return 0; // same object
- if(m.Type() != n.Type()) m.SetError(m.RADIX_ERR, "LLCompare", 206);
-
- //The number of figures is different.
- if( m.aHead != n.aHead ) return m.aHead > n.aHead ? 1 : -1;
- //Here m.aHead = n.aHead.
- const fType* mv = m.ReadFigures();
- const fType* nv = n.ReadFigures();
- register int i;
-
- for(i = (int)m.aHead ; i >= 0; i--) //compare from top
- if( mv[i] != nv[i] ) return mv[i] > nv[i] ? 1 : -1;
-
- return 0; //the same value
- }
slfllcmp.cpp : last modifiled at 2017/03/13 14:32:00(1,035 bytes)
created at 2017/10/07 10:26:50
The creation time of this html file is 2017/11/09 14:52:03 (Thu Nov 09 14:52:03 2017).